package com.thinking.dubbo.config;

import com.thinking.dubbo.api.I18nMessageUtil;
import com.thinking.dubbo.common.LanguageEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @ClassName InitI18nResource
 * @Description TODO  初始化多语言操作
 * @Author tangsixiang@gmail.com
 * @Date 2023/6/5 16:11
 * @Version 1.0
 */
@Component
@Slf4j
public class InitI18nResource  implements InitializingBean {
    @Override
    public void afterPropertiesSet() throws Exception {
        I18nMessageUtil.messageSourceAccessor("default");
         for (LanguageEnum lang: LanguageEnum.values()){
             String language = lang.getLanguage();
             I18nMessageUtil.messageSourceAccessor(language);
          }
         log.info("启动初始化完成-多语言配置完成：",I18nMessageUtil.getMessage(200));
    }
}
